Refactor 404 handling - #880
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR refactors error handling in the Archive plugin by simplifying 404 error handling logic and adding optional chaining for safer repository property access.
- Simplifies 404 error handling by removing the additional condition check
- Adds optional chaining (
?.) when accessing repository properties to prevent potential null/undefined errors
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| } catch (error) { | ||
| if (error.status === 404 && !this.getDesiredArchiveState()) { | ||
| if (error.status === 404) { | ||
| return null |
There was a problem hiding this comment.
Removing the !this.getDesiredArchiveState() condition changes the behavior for 404 errors. This now returns null for all 404 errors regardless of the desired archive state, which may not be the intended behavior. Consider documenting why this condition was removed or verify this change doesn't break existing functionality.
| return null | |
| if (!this.getDesiredArchiveState()) { | |
| return null | |
| } |
There was a problem hiding this comment.
When the repo is not existing, whether to archive or unArchive doesn't make much of a difference. We cannot throw an Error and stop further processing.
This pull request makes small improvements to the
Archiveplugin by simplifying error handling and making the code more robust when accessing repository properties.